/* Controller */

#import <Cocoa/Cocoa.h>


// Menu tag and when the menu is enabled
#define MN_TAG_ALWAYS	0
#define MN_TAG_PATH		1
#define MN_TAG_IMAGE	2
#define MN_TAG_JPEG		3
#define MN_TAG_MASK		0x03


#define PREF_KEY_LAST_FOLDER	@"LastFolder"


@class ExifController;
@class PhotoBrowser;
@class PhotoSlideShow;
@class PhotoViewer;
@class PreferencesData;
@class SlideshowManager;
@class SlideshowModel;
@class ThumbData;

@interface Controller : NSObject
{
	IBOutlet NSMenuItem	*menuSortByDates;
	IBOutlet NSMenuItem	*menuSortByNames;
	IBOutlet NSMenuItem	*menuSortByTypes;
	IBOutlet NSMenuItem	*menuSortByThumbs;
	IBOutlet NSMenu		*imageMenu;
	IBOutlet NSMenu		*directoryMenu;


	PreferencesData		*prefsData;

	NSUserDefaults		*userPreferences;
	NSSound				*soundToTrash;
	NSMutableArray		*browsers;
	NSMutableArray		*viewers;
	NSMutableArray		*slideshows;
	SlideshowManager	*ssManager;

	NSString			*lastMoveOrCopyFolder;
}

// Actions
- (IBAction) browseFolder:(id)sender;
- (IBAction) newWindow:(id)sender;
- (IBAction) newViewerWindow:(id)sender;
- (IBAction) preferences:(id)sender;

+ (Controller*) sharedController;
+ (int) mediaTypeForFile:(NSString*) file;

- (NSSound *) trashSound;
- (NSUserDefaults*) userPreferences;

- (void) browserClosing:(PhotoBrowser*) pb;
- (PhotoViewer*) openImageInViewer:(NSString*) file;
- (PhotoSlideShow*) startAutoSlideshow:(NSString *) folderName;
- (PhotoSlideShow*) openSlideshowFile:(NSString*) filename;
- (PhotoSlideShow*) openSlideshow:(SlideshowModel*) model   show:(BOOL)show;
- (void) manageSlideshows;
- (void) revealInFinder:(NSString*) file;
- (void) setToExifDate:(NSArray *) tdList;
- (void) shiftExifDate:(NSArray*) tdList;
- (void) shiftFileDate:(NSArray*) tdList;
- (void) showInfoDialog:(ExifController**) pexifDialog  file:(NSString*) file;
- (void) slideshowClosing:(PhotoSlideShow*) pv;
- (void) slideshowManagerClosing;
- (NSString*) stringFromErrorCode:(int) error;
- (void) viewerClosing:(PhotoViewer*) pv;

- (void) updateSpecialMenus:(NSMenuItem*) menuItem;

- (PreferencesData*) preferencesData;

- (void) setLastMoveOrCopyFolder:(NSString*)newFolder;
- (NSString*) lastMoveOrCopyFolder;

- (id) activeBrowserOrViewer;
- (PhotoBrowser*) createBrowser;
- (PhotoSlideShow*) createSlideshow:(BOOL) show;
- (PhotoViewer*) createViewer;
- (PhotoBrowser*) getOrCreateBrowser;

- (BOOL) isSlideshowFile:(NSString*) filename;
- (BOOL) isSupportedFile:(NSString*) filename;
- (void) filterImageFiles:(NSMutableArray*) allFiles;

- (NSMenu*) imageMenu;
- (NSMenu*) directoryMenu;

// Dragging helpers
- (NSDragOperation) draggingEnteredHelper:(id <NSDraggingInfo>) sender;
- (BOOL) prepareForDragOperationHelper:(id <NSDraggingInfo>) sender;
- (BOOL) performDragOperationHelper:(id <NSDraggingInfo>) sender;


@end

